/*
 * Universe.h
 *
 *  Created on: 05.06.2012
 *      Author: sebastian
 */

#ifndef UNIVERSE_H_
#define UNIVERSE_H_

#include <pthread.h>
#include "PhysicalObject.h"
#include <list>
#include <vector>
#include <string>


class Universe {  //TODO: mark as singleton...
	friend void createDummyWorld(Universe *u); //TODO: NO fuckin' friends!
private:
	pthread_t thread_;

	bool isRunning_;

	int stepCount_;
	void doStep();

	std::vector<PhysicalObject*> objects_; //memoryleaks on remove single items??? better use lists?

	std::list<Vec*> Forces_;

	std::string cachedString_;

public:

	void start();
	static void* run(void* u);

	void stop();
	Universe();
	virtual ~Universe();

	void addPhysicalObject (PhysicalObject * pObject);

	///@return universe Json string that is needed by js map view
	std::string toString();

	int getTime() const;
};

#endif /* UNIVERSE_H_ */
